package com.zretc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zretc.dao.CinemaFirstPageMapper;
import com.zretc.entity.Cinema;
import com.zretc.service.CinemaFirstPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CinemaFirstPageServiceImpl implements CinemaFirstPageService {

    @Autowired
    private CinemaFirstPageMapper cinemaFirstPageMapper;

    @Override
    public PageInfo<Cinema> getCinemaDescPage(Map<String, String> params) {

        // 获取当前页数
        int pageNum = Integer.parseInt(params.get("pageNum"));
        // 获取条数
        int pageSize = Integer.parseInt(params.get("pageSize"));

        // 1.开始分页
        PageHelper.startPage(pageNum,pageSize);

        // 调用dao层实现
        List<Cinema> cinemaCollectCount = cinemaFirstPageMapper.findCinemaCollectCount();

        // 3.包装到PageInfo对象
        PageInfo<Cinema> PageInfo = new PageInfo<>(cinemaCollectCount);

        return PageInfo;
    }
}
